package lc.q300_350;

public class Q342 {

    public boolean isPowerOfFour(int n) {
        if (n <= 0) {
            return false;
        }
        if (n == 1) {
            return true;
        }
        if ((n & 1) != 0 || (n & 11) != 0) {
            // 末两位不是0
            return false;
        }
        return isPowerOfFour(n >> 2);
    }

    public boolean isPowerOfFour2(int n) {
        // 如果是4的倍数
        return n > 0 && ((n & (n - 1)) == 0) && ((n & 0xaaaaaaaa) == 0);
    }

    public static void main(String[] args) {
        Q342 q342 = new Q342();
        System.out.println(q342.isPowerOfFour(32));
    }
}
